<template>
  <div >
        <el-form :model="queryParams" ref="queryForm" :inline="true"  label-width="68px" @submit.native.prevent>
          <el-form-item label="评教批次" prop="status">
            <el-select
              v-model="queryParams.semCode"
              placeholder="评教批次"
              clearable
              size="small"
              style="width: 240px"
              @change="getEvaluationLog"
            >
            <el-option
                v-for="dict in sems"
                :key="dict.id"
                :label="dict.format"
                :value="dict.id"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="教师名称" prop="teachName">
            <el-input
              v-model="queryParams.teachName"
              placeholder="模糊查询"
              clearable
              size="small"
              style="width: 240px"
              @keyup.enter.native="getEvaluationLog"
            />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="getEvaluationLog">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>
        <el-table v-loading="loading" :data="evaluationLogList" :header-cell-style="getRowClass">
          <el-table-column label="ID" align="center" key="id" prop="id" v-if="columns[1].visible" :show-overflow-tooltip="true" />
          <el-table-column label="批次" align="center" key="semesterName" prop="semesterName" v-if="columns[1].visible" :show-overflow-tooltip="true" />
          <el-table-column label="被评教师" align="center" key="teachName" prop="teachName" v-if="columns[1].visible" :show-overflow-tooltip="true" />
          <el-table-column label="评教人" align="center" key="userName" prop="userName" v-if="columns[2].visible" :show-overflow-tooltip="true" />
          <el-table-column label="课程名字"  align="center" key="courseName" prop="courseName"  />
          <el-table-column label="指标" align="center" key="indicatorName" prop="indicatorName" v-if="columns[4].visible" :show-overflow-tooltip="true" />
          <el-table-column label="评教类型" align="center" key="evalType" prop="evalType" v-if="columns[4].visible" :show-overflow-tooltip="true" />
          <el-table-column label="评分值" align="center" key="score" prop="score" v-if="columns[4].visible" :show-overflow-tooltip="true" />
        </el-table>


        <pagination
          v-show="this.sum>0"
          :total="this.sum"
          :page.sync='queryParams.page'
          :limit.sync='queryParams.number'
          @pagination="getEvaluationLog(false)"
        />
  </div>
</template>

<script>
import {getSemsApi} from "@/api/system/common"
import {getEvaluationLogApi} from "@/api/system/evaluation"
export default {
  name: "user",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 用户表格数据
      evaluationLogList: [],
      sems:[],
      sum: 0,
      //评教页
      open: false,
      // 查询参数
      queryParams: {
        page: 1,
        number: 10,
        teachName: undefined
      },
      // 列信息
      columns: [
        { key: 0, label: `用户编号`, visible: true },
        { key: 1, label: `用户名称`, visible: true },
        { key: 2, label: `登录账号`, visible: true },
        { key: 3, label: `部门名称`, visible: true },
        { key: 4, label: `性别`, visible: true },
        { key: 5, label: `手机号码`, visible: true },
        { key: 6, label: `邮箱`, visible: true },
        { key: 7, label: `状态`, visible: true },
        { key: 8, label: `创建时间`, visible: true }
      ],
      // 表单校验
      rules: {
        
      }
    };
  },
  watch: {

  },
  created() {
    getSemsApi().then(data=>{
      this.sems = data.data;
      if(this.sems!=null && this.sems!=[]){
        this.queryParams.semCode = this.sems[0].id;
        this.getEvaluationLog();
      }
    })
  },
  methods: {
    getRowClass ({ rowIndex }) {
      if (rowIndex == 0) {
        return 'background:#afdfe4'
      } else {
        return ''
      }
    },
    //查询
    getEvaluationLog(){
     getEvaluationLogApi(this.queryParams).then(data=>{
        this.evaluationLogList = data.data.returnDate;
        this.sum = data.data.paginationData.sum;
        this.loading = false;
      }).catch(()=>{
        this.evaluationLogList = null;
        this.sum = 0;
        this.loading = false;
      })
    },
    /** 重置按钮操作 */
    resetQuery() {
      if (this.$refs["queryForm"]) {
		    this.$refs["queryForm"].resetFields();
	    }
      this.getEvaluationLog();
    }
    
  }
};
</script>

<style scoped>
  .mainTitle{
    display:flex;
  }
  .title{
    margin:10px auto;

    font-size: 40px;
  }
  .btton{
   text-align:center;
  }
</style>
